void CLogTrigger::EndTrigger(const void *pBody, int nLen, CAvenueMsgHandler *pHandler, SLogInfo &sLog, const map<string, vector<string> >* mapDefValue) { if (sLog.isBNB) { if (sLog.pItem->nResSize == 0 ) { BuildLogInfo(sLog, "NULL"); return; } string strRes[2]; if (nLen > 0) { pHandler->Decode(pBody, nLen); vecTriggerItem user1(sLog.pItem->vecRes.begin(), sLog.pItem->vecRes.begin()+sLog.pItem->nResSize/2); vecTriggerItem user2(sLog.pItem->vecRes.begin()+sLog.pItem->nResSize/2, sLog.pItem->vecRes.end()); strRes[0] = BuildLog(pHandler, mapDefValue, user1, sLog.mapKey); strRes[1] = BuildLog(pHandler, mapDefValue, user2, sLog.mapKey2); } else { strRes[0] = GetDefaultValue(sLog.pItem->nResSize); strRes[1] = strRes[0]; } BuildLogInfo(sLog, strRes[0]); char szBuf[MAX_LOG_BUFFER]; snprintf(szBuf, sizeof(szBuf)-1, "%s, %s, %s, %s, %s, %s", ASC_VERSION, sLog.mapKey2[1].c_str(), sLog.mapKey2[2].c_str(), sLog.mapKey2[3].c_str(), sLog.strReq[1].c_str(), strRes[1].c_str()); sLog.plusLogInfo = szBuf; } else { string strRes; if (nLen > 0) { SS_XLOG(XLOG_DEBUG,"CLogTrigger::%s xxx\n",__FUNCTION__); pHandler->Decode(pBody, nLen); if (pHandler!=NULL) { strRes = BuildLog(pHandler, mapDefValue, sLog.pItem->vecRes, sLog.mapKey); SS_XLOG(XLOG_DEBUG,"CLogTrigger::%s %d value[%s]\n",__FUNCTION__,sLog.pItem->vecRes.size(),strRes.c_str()); } } BuildLogInfo(sLog, strRes); } }
void CLogTrigger::BeginDataTrigger(SLogInfo& sInfo, CAvenueMsgHandler *pReqHandler, CAvenueMsgHandler *pRspHandler, int nServId, int nMsgId, const map<string, vector<string> >* mapDefValue) { sInfo.pItem = CTriggerConfig::Instance()->GetInfo(TRIGGERTYPE, nServId, nMsgId); if (sInfo.pItem != NULL) { string strReq = BuildLog(pReqHandler, NULL, sInfo.pItem->vecReq, sInfo.mapKey); string strRsp = BuildLog(pRspHandler, mapDefValue, sInfo.pItem->vecRes, sInfo.mapKey); sInfo.strReq[0] = strReq + "@_@" + strRsp; } SS_XLOG(XLOG_DEBUG,"CLogTrigger::%s service[%d],msg[%d] value[%s]\n", __FUNCTION__,nServId, nMsgId,sInfo.strReq[0].c_str()); }
void CLogTrigger::EndTrigger(const void *pBuffer, int nLen, SLogInfo &sLog) { const STriggerItem *pItem = sLog.pItem; if (pItem->nResSize == 0 ) { BuildLogInfo(sLog, "NULL"); return; } string strRes; if (pBuffer == NULL) { strRes = GetDefaultValue(pItem->nResSize); } else { SSapMsgHeader *pHead = (SSapMsgHeader *)pBuffer; void *pBody = (unsigned char *)pBuffer + pHead->byHeadLen; int nBodyLen = nLen - pHead->byHeadLen; if (/* nBodyLen > 0 &&*/ m_pConfig != NULL) { CAvenueMsgHandler oHandler(sLog.serviceName, false, m_pConfig); oHandler.Decode(pBody, nBodyLen); strRes = BuildLog(&oHandler, NULL, pItem->vecRes, sLog.mapKey); } else { strRes = GetDefaultValue(pItem->nResSize); } } BuildLogInfo(sLog, strRes); }
void CLogTrigger::BeginTrigger(const void *pBuffer, int nLen, SLogInfo &sLog) { SSapMsgHeader *pHead = (SSapMsgHeader *)pBuffer; int nServId = ntohl(pHead->dwServiceId); int nMsgId = ntohl(pHead->dwMsgId); sLog.pItem = CTriggerConfig::Instance()->GetInfo(TRIGGERTYPE,nServId, nMsgId); if (sLog.pItem == NULL || sLog.pItem->nReqSize == 0) { return; } void *pBody = (unsigned char *)pBuffer + pHead->byHeadLen; int nBodyLen = nLen - pHead->byHeadLen; if (nBodyLen == 0) { sLog.strReq[0] = GetDefaultValue(sLog.pItem->nReqSize); return; } if (m_pConfig == NULL || 0 != m_pConfig->GetServiceNameById(nServId, nMsgId, sLog.serviceName)) { SS_XLOG(XLOG_DEBUG,"CLogTrigger::%s service[%d],msg[%d] not found\n", __FUNCTION__,nServId, nMsgId); sLog.strReq[0] = GetDefaultValue(sLog.pItem->nReqSize); return; } CAvenueMsgHandler oHandler(sLog.serviceName,true,m_pConfig); oHandler.Decode(pBody, nBodyLen); sLog.strReq[0] = BuildLog(&oHandler, NULL, sLog.pItem->vecReq, sLog.mapKey); }
void CLogTrigger::EndDataTrigger(SLogInfo &sLog, const map<string, vector<string> >* mapDefValue) { string strDataDef = BuildLog(NULL, mapDefValue, sLog.pItem->vecDataDef, sLog.mapKey); BuildLogInfo(sLog, strDataDef); }
void BuildWindows::Build(const String& buildPath) { ToolEnvironment* tenv = GetSubsystem<ToolEnvironment>(); buildPath_ = AddTrailingSlash(buildPath) + GetBuildSubfolder(); BuildLog("Starting Windows Deployment"); Initialize(); if (!BuildClean(buildPath_)) return; BuildSystem* buildSystem = GetSubsystem<BuildSystem>(); FileSystem* fileSystem = GetSubsystem<FileSystem>(); String rootSourceDir = tenv->GetRootSourceDir(); String playerBinary = tenv->GetPlayerBinary(); String d3d9dll = GetPath(playerBinary) + "/D3DCompiler_47.dll"; if (!BuildCreateDirectory(buildPath_)) return; if (!BuildCreateDirectory(buildPath_ + "/AtomicPlayer_Resources")) return; String resourcePackagePath = buildPath_ + "/AtomicPlayer_Resources/AtomicResources" + PAK_EXTENSION; GenerateResourcePackage(resourcePackagePath); if (buildFailed_) return; if (!BuildCopyFile(playerBinary, buildPath_ + "/AtomicPlayer.exe")) return; if (!BuildCopyFile(d3d9dll, buildPath_ + "/D3DCompiler_47.dll")) return; BuildAtomicNET(); BuildLog("Windows Deployment Complete"); buildSystem->BuildComplete(PLATFORMID_WINDOWS, buildPath_); }
void CLogTrigger::BeginTrigger(CAvenueMsgHandler *pHandler, int nServId, int nMsgId, SLogInfo& sInfo) { sInfo.pItem = CTriggerConfig::Instance()->GetInfo(TRIGGERTYPE,nServId, nMsgId); if (sInfo.pItem != NULL && sInfo.pItem->nReqSize > 0) { if (nServId == BNB_SERVICEID) { sInfo.isBNB = true; vecTriggerItem user1(sInfo.pItem->vecReq.begin(), sInfo.pItem->vecReq.begin()+sInfo.pItem->nReqSize/2); vecTriggerItem user2(sInfo.pItem->vecReq.begin()+sInfo.pItem->nReqSize/2, sInfo.pItem->vecReq.end()); sInfo.strReq[0] = BuildLog(pHandler, NULL, user1, sInfo.mapKey); sInfo.strReq[1] = BuildLog(pHandler, NULL, user2, sInfo.mapKey2); } else { sInfo.strReq[0] = BuildLog(pHandler, NULL, sInfo.pItem->vecReq, sInfo.mapKey); } } SS_XLOG(XLOG_DEBUG,"CLogTrigger::%s service[%d],msg[%d] value[%s]\n", __FUNCTION__,nServId, nMsgId,sInfo.strReq[0].c_str()); }
void BuildWindows::BuildNative(const String& buildPath) { BuildLog("Building Native Application"); ToolEnvironment* tenv = GetSubsystem<ToolEnvironment>(); String playerBinary = tenv->GetPlayerBinary(); String d3d9dll = GetPath(playerBinary) + "/D3DCompiler_47.dll"; if (!BuildCopyFile(playerBinary, buildPath_ + "/AtomicPlayer.exe")) return; if (!BuildCopyFile(d3d9dll, buildPath_ + "/D3DCompiler_47.dll")) return; }
/** * @brief writing a simple log file */ bool PrepareLogFile() { // Clean up log directory CleanUpLogDirectory(); // start a thread for logging auto& log_manager = logging::LogManager::GetInstance(); log_manager.SetLogDirectoryName(state.log_file_dir); log_manager.SetLogFileName(state.log_file_dir + "/" + logging::WriteBehindFrontendLogger::wbl_log_path); if (log_manager.ContainsFrontendLogger() == true) { LOG_ERROR("another logging thread is running now"); return false; } // Get an instance of the storage manager to force posix_fallocate // to be invoked before we begin benchmarking auto& storage_manager = storage::StorageManager::GetInstance(); auto tmp = storage_manager.Allocate(BACKEND_TYPE_MM, 1024); storage_manager.Release(BACKEND_TYPE_MM, tmp); // Pick sync commit mode switch (state.asynchronous_mode) { case ASYNCHRONOUS_TYPE_SYNC: log_manager.SetSyncCommit(true); break; case ASYNCHRONOUS_TYPE_ASYNC: case ASYNCHRONOUS_TYPE_DISABLED: log_manager.SetSyncCommit(false); break; case ASYNCHRONOUS_TYPE_INVALID: throw Exception("Invalid asynchronous mode : " + std::to_string(state.asynchronous_mode)); } Timer<> timer; std::thread thread; // Initializing logging module StartLogging(thread); timer.Start(); // Build the log BuildLog(); // Stop frontend logger if in a valid logging mode if (peloton_logging_mode != LOGGING_TYPE_INVALID) { // Wait for the mode transition :: LOGGING -> TERMINATE -> SLEEP if (log_manager.EndLogging()) { thread.join(); } } timer.Stop(); // Pick metrics based on benchmark type double throughput = 0; double latency = 0; if (state.benchmark_type == BENCHMARK_TYPE_YCSB) { throughput = ycsb::state.throughput; latency = ycsb::state.latency; } else if (state.benchmark_type == BENCHMARK_TYPE_TPCC) { throughput = tpcc::state.throughput; latency = tpcc::state.latency; } // Log the build log time if (state.experiment_type == EXPERIMENT_TYPE_THROUGHPUT) { WriteOutput(throughput); } else if (state.experiment_type == EXPERIMENT_TYPE_LATENCY) { WriteOutput(latency); } return true; }
/** * @brief writing a simple log file */ bool PrepareLogFile() { if (chdir(state.log_file_dir.c_str())) { LOG_ERROR("change directory failed"); } // start a thread for logging 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) { // Launching a thread for logging if (!log_manager.IsInLoggingMode()) { // Set sync commit mode log_manager.SetSyncCommit(false); // Wait for standby mode auto local_thread = std::thread( &peloton::logging::LogManager::StartStandbyMode, &log_manager); thread.swap(local_thread); log_manager.WaitForModeTransition(peloton::LOGGING_STATUS_TYPE_STANDBY, true); // Clean up database tile state before recovery from checkpoint log_manager.PrepareRecovery(); // Do any recovery log_manager.StartRecoveryMode(); // Wait for logging mode log_manager.WaitForModeTransition(peloton::LOGGING_STATUS_TYPE_LOGGING, true); // Done recovery log_manager.DoneRecovery(); } } // Build the log BuildLog(); // Stop frontend logger if in a valid logging mode if (peloton_logging_mode != LOGGING_TYPE_INVALID) { // Wait for the mode transition :: LOGGING -> TERMINATE -> SLEEP if (log_manager.EndLogging()) { thread.join(); } } timer.Stop(); auto duration = timer.GetDuration(); auto throughput = (ycsb::state.transaction_count * ycsb::state.backend_count) / duration; // Log the build log time 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; }
void BuildWindows::BuildAtomicNET() { // AtomicNET FileSystem* fileSystem = GetSubsystem<FileSystem>(); ToolEnvironment* tenv = GetSubsystem<ToolEnvironment>(); ToolSystem* tsystem = GetSubsystem<ToolSystem>(); Project* project = tsystem->GetProject(); String projectResources = project->GetResourcePath(); String assembliesPath = projectResources + "Assemblies/"; // if no assemblies path, no need to install AtomicNET if (!fileSystem->DirExists(assembliesPath)) return; Vector<String> results; fileSystem->ScanDir(results, assembliesPath, "*.dll", SCAN_FILES, true); // if no assembiles in Assemblies path, no need to install AtomicNET if (!results.Size()) return; BuildLog("Building AtomicNET"); fileSystem->CreateDir(buildPath_ + "/AtomicPlayer_Resources/AtomicNET"); fileSystem->CreateDir(buildPath_ + "/AtomicPlayer_Resources/AtomicNET/Atomic"); fileSystem->CreateDir(buildPath_ + "/AtomicPlayer_Resources/AtomicNET/Atomic/Assemblies"); fileSystem->CopyDir(tenv->GetNETCoreCLRAbsPath(), buildPath_ + "/AtomicPlayer_Resources/AtomicNET/CoreCLR"); fileSystem->CopyDir(tenv->GetNETTPAPaths(), buildPath_ + "/AtomicPlayer_Resources/AtomicNET/Atomic/TPA"); // Atomic Assemblies const String& assemblyLoadPaths = tenv->GetNETAssemblyLoadPaths(); Vector<String> paths = assemblyLoadPaths.Split(';'); for (unsigned i = 0; i < paths.Size(); i++) { Vector<String> loadResults; fileSystem->ScanDir(loadResults, paths[i], "*.dll", SCAN_FILES, true); for (unsigned j = 0; j < loadResults.Size(); j++) { String pathName, fileName, ext; SplitPath(loadResults[j], pathName, fileName, ext); if (fileName != "AtomicNETEngine") continue; fileSystem->Copy(paths[i] + "/" + loadResults[j], ToString("%s/AtomicPlayer_Resources/AtomicNET/Atomic/Assemblies/%s.dll", buildPath_.CString(), fileName.CString())); } } // Project assemblied for (unsigned i = 0; i < results.Size(); i++) { String pathName, fileName, ext; SplitPath(results[i], pathName, fileName, ext); fileSystem->Copy(assembliesPath + results[i], ToString("%s/AtomicPlayer_Resources/AtomicNET/Atomic/Assemblies/%s.dll", buildPath_.CString(), fileName.CString())); } }
void BuildWindows::Build(const String& buildPath) { BuildSystem* buildSystem = GetSubsystem<BuildSystem>(); FileSystem* fileSystem = GetSubsystem<FileSystem>(); ToolEnvironment* tenv = GetSubsystem<ToolEnvironment>(); ToolSystem* tsystem = GetSubsystem<ToolSystem>(); Project* project = tsystem->GetProject(); buildPath_ = AddTrailingSlash(buildPath); if (!resourcesOnly_) buildPath_ += GetBuildSubfolder(); BuildLog("Starting Windows Deployment"); Initialize(); if (!resourcesOnly_ && !BuildClean(buildPath_)) return; String rootSourceDir = tenv->GetRootSourceDir(); if (!BuildCreateDirectory(buildPath_)) return; if (!resourcesOnly_ && !BuildCreateDirectory(buildPath_ + "/AtomicPlayer_Resources")) return; String resourcePackagePath = buildPath_ + "/AtomicPlayer_Resources/AtomicResources" + PAK_EXTENSION; if (resourcesOnly_) { resourcePackagePath = buildPath_ + "/AtomicResources" + PAK_EXTENSION; } GenerateResourcePackage(resourcePackagePath); if (buildFailed_) return; if (resourcesOnly_) return; if (!BuildCreateDirectory(buildPath_ + "/Settings")) return; String engineJSON(GetSettingsDirectory() + "/Engine.json"); if (fileSystem->FileExists(engineJSON)) { if (!BuildCopyFile(engineJSON, buildPath_ + "/Settings/Engine.json")) return; } // TODO: Set project as managed and don't key off project assembly if (fileSystem->FileExists(project->GetResourcePath() + project->GetProjectSettings()->GetName() + ".dll")) { if (!BuildManaged(buildPath)) return; } else { BuildNative(buildPath); } BuildLog("Windows Deployment Complete"); buildSystem->BuildComplete(PLATFORMID_WINDOWS, buildPath_); }