From 17cf21bcf8a2e29d2cbcf0a313474d2a4ee44f5d Mon Sep 17 00:00:00 2001 From: Tadao Tanikawa Date: Fri, 20 Nov 2020 23:36:23 +0900 Subject: Re-organized sub-directory by category Since all the sub-directories were placed in the first level, created sub-directories, "hal", "module", and "service" for classification and relocated each component. Signed-off-by: Tadao Tanikawa Change-Id: Ifdf743ac0d1893bd8e445455cf0d2c199a011d5c --- .../src/heartbeat/ss_hb_service_protocol.cpp | 184 +++++++++++++++++++++ 1 file changed, 184 insertions(+) create mode 100755 service/system/system_manager/server/src/heartbeat/ss_hb_service_protocol.cpp (limited to 'service/system/system_manager/server/src/heartbeat/ss_hb_service_protocol.cpp') diff --git a/service/system/system_manager/server/src/heartbeat/ss_hb_service_protocol.cpp b/service/system/system_manager/server/src/heartbeat/ss_hb_service_protocol.cpp new file mode 100755 index 0000000..5fb4e00 --- /dev/null +++ b/service/system/system_manager/server/src/heartbeat/ss_hb_service_protocol.cpp @@ -0,0 +1,184 @@ +/* + * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/////////////////////////////////////////////////////////////////////////////// +/// \ingroup tag_SystemManager +/// \brief This file provides support for the application heartbeat system. +/// +/////////////////////////////////////////////////////////////////////////////// +#include +#include +#include +#include +#include +#include +#include +#include + +#include "ss_hb_thread.h" +#include "ss_sm_systemmanagerlog.h" + +/***************************************************************************** + @ingroup: SS_SystemManager + @brief: HBOnTimerExpiry + @note: . + @param HANDLE - Handle to message queue of HeartBeat Service. + @return EFrameworkunifiedStatus + *****************************************************************************/ +EFrameworkunifiedStatus CHeartBeatThread::HBOnTimerExpiry(HANDLE f_hThread) { + FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_FUNC, __FUNCTION__, "+"); + EFrameworkunifiedStatus l_eStatus; + + // check heart beat replies received from clients. + l_eStatus = HBCheckHeartBeatResponses(f_hThread); + LOG_STATUS_IF_ERRORED(l_eStatus, "HBCheckHeartBeatResponses()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length) + + // send heart beat requests to clients + l_eStatus = HBSendRequest(f_hThread); + LOG_STATUS_IF_ERRORED(l_eStatus, "HBSendRequest()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length) + + FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_FUNC, __FUNCTION__, "-"); + return (l_eStatus); +} + +/***************************************************************************** + @ingroup: SS_SystemManager + @brief: HBOnClientResponse + @note: . + @param HANDLE - Handle to message queue of HeartBeat Service. + @return EFrameworkunifiedStatus OK or Fail + *****************************************************************************/ +EFrameworkunifiedStatus CHeartBeatThread::HBOnClientResponse(HANDLE f_hThread) { + EFrameworkunifiedStatus l_eStatus; + FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_FUNC, __FUNCTION__, "+"); + l_eStatus = m_oSessionHandler.HBProcessClientResponse(f_hThread); + LOG_STATUS_IF_ERRORED(l_eStatus, "m_oSessionHandler.HBProcessClientResponse(f_hThread)"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length) + FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} + +/***************************************************************************** + @ingroup: SS_SystemManager + @brief: HBOnPeriodicStatusRequest + @note: . + @param HANDLE - Handle to message queue of HeartBeat Service. + @return EFrameworkunifiedStatus OK or Fail + *****************************************************************************/ +EFrameworkunifiedStatus CHeartBeatThread::HBOnPeriodicStatusRequest(HANDLE f_hThread) { + EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; + FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_FUNC, __FUNCTION__, "+"); + // LCOV_EXCL_BR_START 4: NSFW error case. + if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSendParent(f_hThread, SS_HEARTBEAT_PERIODIC_RESP, 0, NULL))) { + // LCOV_EXCL_BR_STOP + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + LOG_ERROR("FrameworkunifiedSendParent(SS_HEARTBEAT_PERIODIC_RESP)"); // LCOV_EXCL_LINE 4: NSFW error case. + } else { + FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_INFO, __FUNCTION__, "Successful"); + } + + FRAMEWORKUNIFIEDLOG(ZONE_PERIODIC_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} + +/***************************************************************************** + @ingroup: SS_SystemManager + @brief: HBOnPeriodicStatusRequest + @note: . + @param HANDLE - Handle to message queue of HeartBeat Service. + @return EFrameworkunifiedStatus OK or Fail + *****************************************************************************/ +EFrameworkunifiedStatus CHeartBeatThread::HBOnAvailCheckRequest(HANDLE f_hThread) { + FRAMEWORKUNIFIEDLOG(ZONE_STATE, __FUNCTION__, "+"); + + EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusOK; + THbAvailCheck check; + l_eStatus = m_oSessionHandler.HBAvailableCheck(check); + SS_ASERT(l_eStatus == eFrameworkunifiedStatusOK); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length) + + // LCOV_EXCL_BR_START 4: NSFW error case. + if (eFrameworkunifiedStatusOK != (l_eStatus = FrameworkunifiedSendParent(f_hThread, SS_HEARTBEAT_AVAIL_CHECK_RESP, sizeof(check), &check))) { + // LCOV_EXCL_BR_STOP + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + LOG_ERROR("FrameworkunifiedSendParent(SS_HEARTBEAT_AVAIL_CHECK_RESP)"); // LCOV_EXCL_LINE 4: NSFW error case. + } + + return l_eStatus; +} + +/***************************************************************************** + @ingroup: SS_SystemManager + @brief: HBOnRemoveModule + @note: . + @param HANDLE - Handle to message queue of HeartBeat Service. + @return EFrameworkunifiedStatus OK or Fail + *****************************************************************************/ +EFrameworkunifiedStatus CHeartBeatThread::HBOnRemoveModule(HANDLE f_hThread) { + EFrameworkunifiedStatus l_eStatus; + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); + + TSMRequestMessage tReqMsgData; + // ReadMsg(): * + // Check hApp ptr, msg size, msg reception, read msg if all ok. * + // Report any errors found. * + // * + // LCOV_EXCL_BR_START 4: NSFW error case. + if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg (f_hThread, tReqMsgData))) { + // LCOV_EXCL_BR_STOP + AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert + LOG_ERROR("ReadMsg()"); // LCOV_EXCL_LINE 4: NSFW error case. + } else { + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, + " %s is required to be Deleted from HeartBeat Monitor List", tReqMsgData.pstModuleName); + + // delete module entry from map + l_eStatus = m_oSessionHandler.HBDeleteRegisteredClientEntry(f_hThread, tReqMsgData.pstModuleName); + LOG_STATUS_IF_ERRORED(l_eStatus, "m_oSessionHandler.HBDeleteRegisteredProcessEntry()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length) + } + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} + +/***************************************************************************** + @ingroup: SS_SystemManager + @brief: HBOnAppendModule + @note: . + @param HANDLE - Handle to message queue of HeartBeat Service. + @return EFrameworkunifiedStatus OK or Fail + *****************************************************************************/ +EFrameworkunifiedStatus CHeartBeatThread::HBOnAppendModule(HANDLE f_hThread) { + EFrameworkunifiedStatus l_eStatus; + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+"); + + TSMRequestMessage tReqMsgData; + // ReadMsg(): * + // Check hApp ptr, msg size, msg reception, read msg if all ok. * + // Report any errors found. * + // * + if (eFrameworkunifiedStatusOK != (l_eStatus = ReadMsg < TSMRequestMessage > (f_hThread, tReqMsgData))) { + LOG_ERROR("ReadMsg()"); + } else { + FRAMEWORKUNIFIEDLOG(ZONE_INFO, __FUNCTION__, + " %s is required to be Appended from HeartBeat Monitor List", tReqMsgData.pstModuleName); + + // append module entry from map + SubscriberName l_Subscriber = tReqMsgData.pstModuleName; + l_eStatus = m_oSessionHandler.HBEntrySubscriber(l_Subscriber); // LCOV_EXCL_BR_LINE 11:unexpected branch // NOLINT(whitespace/line_length) + LOG_STATUS_IF_ERRORED(l_eStatus, "m_oSessionHandler.HBEntrySubscriber()"); // LCOV_EXCL_BR_LINE 15: marco defined in ss_templates.h // NOLINT(whitespace/line_length) + } + FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-"); + return l_eStatus; +} +// EOF -- cgit 1.2.3-korg