Explorar o código

!10129 合并启动器等待健康的逻辑
Merge pull request !10129 from 80174847/uos_bootbalance20231121

杨诗友80174847 hai 1 ano
pai
achega
3e2a630c22

+ 19 - 16
Module/mod_vtmloader/VtmLoaderFSM.cpp

@@ -711,13 +711,13 @@ void CVtmLoaderFSM::s4_on_entry()
 	LOG_FUNCTION();
 	LogWarn(Severity_Low, Error_Succeed, VtmLoader_BootInfoPrint, "Operating 阶段实体加载完成");
 	//oiltmp wait for analyse progress, then change to app log format
-	LogWarn(Severity_Low, Error_Succeed, VtmLoader_NetCard_Cost, CSimpleStringA::Format("%d", m_ullNetCardCost));
-	LogWarn(Severity_Low, Error_Succeed, VtmLoader_NetworkDetect_Cost, CSimpleStringA::Format("%d", m_ullNetDetectCost));
-	LogWarn(Severity_Low, Error_Succeed, VtmLoader_GetConfig_Cost, CSimpleStringA::Format("%d", m_ullGetConfigCost));
+	LogWarn(Severity_Low, Error_Succeed, VtmLoader_NetCard_Cost, CSimpleStringA::Format("%d", m_ullNetCardCost).GetData());
+	LogWarn(Severity_Low, Error_Succeed, VtmLoader_NetworkDetect_Cost, CSimpleStringA::Format("%d", m_ullNetDetectCost).GetData());
+	LogWarn(Severity_Low, Error_Succeed, VtmLoader_GetConfig_Cost, CSimpleStringA::Format("%d", m_ullGetConfigCost).GetData());
+	LogWarn(Severity_Low, Error_Succeed, VtmLoader_EntityLoad_Cost, CSimpleStringA::Format("%d", (SP::Module::Comm::RVCGetTickCount() - m_ullEntityLoadStart)/1000).GetData());
 	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode("QLR040210F16")("Stage Operating have done.");
 	NoticeEntityLoadTask* pTask = new NoticeEntityLoadTask(this,Event_VtmLoader_EntityLoad_Finished);
 	GetEntityBase()->GetFunction()->PostThreadPoolTask(pTask);
-	//LogEvent(Severity_Middle, Event_VtmLoader_EntityLoad_Finished, "实体启动完成");
 }
 void CVtmLoaderFSM::s4_on_exit()
 {
@@ -858,10 +858,9 @@ int CVtmLoaderFSM::NetWorkCheckAndGetSetting()
 		while (true)
 		{
 			if (!DetectNetworkLegality(strMsg)) {
-				//LogWarn(Severity_High, Error_Unexpect, VtmLoader_UserCode_NetCard_UnAvaible, strMsg.GetData());
-				//LogWarn(Severity_High, Error_Unexpect, VtmLoader_BootInfoPrint, strMsg.GetData());
+				DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR040210F10").setResultCode("RTA1F00")("can't find valid network interface");
 				LogWarn(Severity_High, Error_Unexpect, VtmLoader_BootInfoPrint, CSimpleStringA::Format("%s。%d 秒后自动重试(第%d次重试)。请检查网线是否插好、网络是否正常"
-					, strMsg.GetData(), m_iDetectInterval / 1000, netcheckCount));
+					, strMsg.GetData(), m_iDetectInterval / 1000, netcheckCount).GetData());
 				//if (tmpTS.Compare("E") != 0)
 				//{
 				//	GetEntityBase()->GetFunction()->SetSysVar("TerminalStage", "E");
@@ -887,6 +886,7 @@ int CVtmLoaderFSM::NetWorkCheckAndGetSetting()
 			return -1;
 		}
 	}
+	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode("QLR040210F11")("connect to http(s) service ok.");
 	m_ullNetDetectCost = (SP::Module::Comm::RVCGetTickCount() - ullTmpStart) / 1000;//second
 	ullTmpStart = SP::Module::Comm::RVCGetTickCount();
 	//拉取配置并通知提前启动的实体(Chromium)
@@ -915,6 +915,7 @@ int CVtmLoaderFSM::EntityLoad()
 {
 	//前提:收到了配置拉取完成的指令,才会进入到这里
 	//为了测试,假装已经拿到了集中配置
+	m_ullEntityLoadStart = SP::Module::Comm::RVCGetTickCount();
 	LogWarn(Severity_Low, Error_Succeed, VtmLoader_BootInfoPrint, "开始加载实体");
 	CSmartPointer<IConfigInfo> spConfigCen,spRunCfg;
 	GetEntityBase()->GetFunction()->OpenConfig(Config_CenterSetting, spConfigCen);
@@ -941,7 +942,7 @@ int CVtmLoaderFSM::EntityLoad()
 		}
 		else
 		{
-			LogWarn(Severity_High, Error_Unexpect, VtmLoader_BootInfoPrint, CSimpleStringA::Format("CoreBoot配置异常,请联系总行开发人员检查(%s)", csCoreBootList.GetData()));
+			LogWarn(Severity_High, Error_Unexpect, VtmLoader_BootInfoPrint, CSimpleStringA::Format("CoreBoot配置异常,请联系总行开发人员检查(%s)", csCoreBootList.GetData()).GetData());
 			DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM).setLogCode("QLR040210F14").setResultCode("RTA1F05")(CSimpleStringA::Format("CoreBoot配置异常,请联系总行开发人员检查(%s)", csCoreBootList.GetData()));
 		}
 		//if have PinPad module
@@ -1245,8 +1246,9 @@ void CVtmLoaderFSM::NoticeEntityLoad(int evtCode)
 				break;
 		}
 		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("Notice HealthManager failed,eErrConn:%d,eErrCall:%d", eErrConn, eErrCall);
+		Sleep(2000);
 		count++;
-	} while (count < 3);
+	} while (count < 100);
 }
 bool CVtmLoaderFSM::DetectHttpActive()
 {
@@ -1394,7 +1396,7 @@ bool CVtmLoaderFSM::GetConfig()
 	LogWarn(Severity_Low, Error_Succeed, VtmLoader_BootInfoPrint, "开始拉取配置");
 	if (Error_Succeed != (eErr = GetEntityBase()->GetFunction()->GetPrivilegeFunction()->InitCfgUrl(channelId, tokenSecret, CommonLaunchUrl, CenterConfigTotal)))
 	{
-		LogWarn(Severity_High, Error_Unexpect, VtmLoader_BootInfoPrint, CSimpleStringA::Format("拉取配置,初始化配置地址失败:0x%x(%s)", eErr, SpStrError(eErr)));
+		LogWarn(Severity_High, Error_Unexpect, VtmLoader_BootInfoPrint, CSimpleStringA::Format("拉取配置,初始化配置地址失败:0x%x(%s)", eErr, SpStrError(eErr)).GetData());
 		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR040210F13").setResultCode("RTA1F01")("Get config,InitCfgUrl failed.");
 		LogEvent(Severity_High, Event_VtmLoader_GetConfig_Fail, "拉取配置,初始化配置地址失败");
 		return false;
@@ -1407,13 +1409,13 @@ bool CVtmLoaderFSM::GetConfig()
 		//if token update failed,we can also update cfg suc
 		if (Error_Succeed != (eErr = GetEntityBase()->GetFunction()->GetPrivilegeFunction()->TryUpdateCfg()))
 		{
-			LogWarn(Severity_High, Error_Unexpect, VtmLoader_BootInfoPrint, CSimpleStringA::Format("拉取配置失败:0x%x(%s)", eErr, SpStrError(eErr)));
+			LogWarn(Severity_High, Error_Unexpect, VtmLoader_BootInfoPrint, CSimpleStringA::Format("拉取配置失败:0x%x(%s)", eErr, SpStrError(eErr)).GetData());
 			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR040210F13").setResultCode("RTA1F03")("Get config, TryUpdateCfg failed:0x%x", eErr);
 			LogEvent(Severity_High, Event_VtmLoader_GetConfig_Fail, "拉取配置失败");
 			return false;
 		}
 	}
-
+	refreshLogLevel();
 
 
 
@@ -1520,7 +1522,8 @@ int CVtmLoaderFSM::HttpConnCheck(CSimpleStringA csHttAddr, HttpAddrType eType)
 #endif
 		if (!bCheckOK)
 		{
-			LogWarn(Severity_Middle, Error_Unexpect, VtmLoader_BootInfoPrint, CSimpleStringA::Format("尝试连接总行服务失败(%s),%d 秒后自动重试(第%d次重试)。请确认终端到总行服务网络是否正常", csHttAddr.GetData(), m_iDetectInterval/1000, httpcheckCount));
+			LogWarn(Severity_Middle, Error_Unexpect, VtmLoader_BootInfoPrint, CSimpleStringA::Format("尝试连接总行服务失败(%s),%d 秒后自动重试(第%d次重试)。请确认终端到总行服务网络是否正常", csHttAddr.GetData(), m_iDetectInterval/1000, httpcheckCount).GetData());
+			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR040210F11").setResultCode("RTA1F06")("connect to http(s) service(%s) failed.", csHttAddr.GetData());
 			m_httpCheckResult[eType] = HttpConnResult_Failed;
 			Sleep(m_iDetectInterval);
 			httpcheckCount++;
@@ -1531,7 +1534,7 @@ int CVtmLoaderFSM::HttpConnCheck(CSimpleStringA csHttAddr, HttpAddrType eType)
 				GetDns(tmpDns);
 				for (int i = 0; i < netList.GetCount(); i++) {
 					LogWarn(Severity_Middle, Error_Unexpect, VtmLoader_BootInfoPrint, CSimpleStringA::Format("(%d)interface:%s; ip:%s; mac:%s; %s", i, netList[i].description.c_str()
-						, netList[i].ip.c_str(), netList[i].mac.c_str(), tmpDns.c_str()));
+						, netList[i].ip.c_str(), netList[i].mac.c_str(), tmpDns.c_str()).GetData());
 				}
 			}
 		}
@@ -1541,9 +1544,9 @@ int CVtmLoaderFSM::HttpConnCheck(CSimpleStringA csHttAddr, HttpAddrType eType)
 			if ((SP::Module::Comm::RVCGetTickCount() - beginTick) > 3000)
 			{
 				LogWarn(Severity_Low, Error_Unexpect, VtmLoader_BootInfoPrint, CSimpleStringA::Format("第(%d)次尝试连接总行服务成功(%s),但是网络偏慢,连接花了(%d)秒,请检查网络!"
-					, httpcheckCount, csHttAddr.GetData(), (SP::Module::Comm::RVCGetTickCount() - beginTick)/1000));
+					, httpcheckCount, csHttAddr.GetData(), (SP::Module::Comm::RVCGetTickCount() - beginTick)/1000).GetData());
 			}
-			LogWarn(Severity_Low, Error_Succeed, VtmLoader_BootInfoPrint, CSimpleStringA::Format("尝试连接总行服务成功(%s)", csHttAddr.GetData()));
+			LogWarn(Severity_Low, Error_Succeed, VtmLoader_BootInfoPrint, CSimpleStringA::Format("尝试连接总行服务成功(%s)", csHttAddr.GetData()).GetData());
 			return 0;
 		}
 	} 

+ 1 - 1
Module/mod_vtmloader/VtmLoaderFSM.h

@@ -149,7 +149,7 @@ private:
 	CSystemStaticInfo m_sysInfo;
 	CSimpleStringA m_strNetworkCheckUrl, m_csErrEntity, m_defaultSystemId;
 	int m_sleepEnterOpMS, m_iCanIgnoreAddrDetect, m_iDetectInterval;
-	ULLINT m_ullMaxAddrDetectTime, m_ullNetCardCost, m_ullNetDetectCost, m_ullGetConfigCost;
+	ULLINT m_ullMaxAddrDetectTime, m_ullNetCardCost, m_ullNetDetectCost, m_ullGetConfigCost, m_ullEntityLoadStart;
 	int m_httpCheckResult[2];
 	//DNS Settings
 	CSimpleStringA m_strDefaultDNS;

+ 5 - 0
Module/mod_vtmloader/VtmLoader_UserCode.h

@@ -6,3 +6,8 @@ const int VtmLoader_BootInfoPrint = 0x10f00205;
 const int VtmLoader_NetCard_Cost = 0x10f00206;
 const int VtmLoader_NetworkDetect_Cost = 0x10f00207;
 const int VtmLoader_GetConfig_Cost = 0x10f00208;
+const int VtmLoader_EntityLoad_Cost = 0x10f00209;
+const int VtmLoader_FailToStartEntity = 0x10f0020a;
+const int VtmLoader_FailToConnectEntity = 0x10f0020b;
+const int VtmLoader_EntityNotInNormal = 0x10f0020c;
+const int VtmLoader_FailToGetEntityInfo = 0x10f0020d;