From a0168db0a025f0e20cb069eaf3259977ee808ebd Mon Sep 17 00:00:00 2001 From: tangfan <1824525929@qq.com> Date: Mon, 28 Mar 2022 19:00:36 +0800 Subject: [PATCH 1/4] add rpc retry Signed-off-by: tangfan <1824525929@qq.com> --- .../componentmanager/component_manager.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp index 0e4271a9..5ef2b8df 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp @@ -43,6 +43,7 @@ IMPLEMENT_SINGLE_INSTANCE(ComponentManager); namespace { constexpr int32_t ENABLE_RETRY_MAX_TIMES = 30; constexpr int32_t DISABLE_RETRY_MAX_TIMES = 30; + constexpr int32_t ENABLE_PARAM_RETRY_TIME = 500 * 1000; } ComponentManager::~ComponentManager() @@ -221,12 +222,24 @@ int32_t ComponentManager::Enable(const std::string &networkId, const std::string if (ret != DH_FWK_SUCCESS) { DHLOGE("GetEnableParam failed, uuid = %s, dhId = %s, errCode = %d", GetAnonyString(uuid).c_str(), dhId.c_str(), ret); - return ret; + for (int32_t retryCount = 0; retryCount < ENABLE_RETRY_MAX_TIMES; retryCount++) { + if (!DHContext::GetInstance().IsDeviceOnline(uuid)) { + DHLOGW("device is already offline, no need try GetEnableParam, uuid = %s", + GetAnonyString(uuid).c_str()); + return ret; + } + if (GetEnableParam(networkId, uuid, dhId, dhType, param) == DH_FWK_SUCCESS) { + DHLOGI("GetEnableParam success, retryCount = %d", retryCount); + break; + } + DHLOGE("GetEnableParam failed, retryCount = %d", retryCount); + usleep(ENABLE_PARAM_RETRY_TIME); + } } auto compEnable = std::make_shared(); auto result = compEnable->Enable(networkId, dhId, param, find->second); if (result != DH_FWK_SUCCESS) { - for (int retryCount = 0; retryCount < ENABLE_RETRY_MAX_TIMES; retryCount++) { + for (int32_t retryCount = 0; retryCount < ENABLE_RETRY_MAX_TIMES; retryCount++) { if (!DHContext::GetInstance().IsDeviceOnline(uuid)) { DHLOGW("device is already offline, no need try enable, uuid = %s", GetAnonyString(uuid).c_str()); return result; @@ -254,7 +267,7 @@ int32_t ComponentManager::Disable(const std::string &networkId, const std::strin auto compDisable = std::make_shared(); auto result = compDisable->Disable(networkId, dhId, find->second); if (result != DH_FWK_SUCCESS) { - for (int retryCount = 0; retryCount < DISABLE_RETRY_MAX_TIMES; retryCount++) { + for (int32_t retryCount = 0; retryCount < DISABLE_RETRY_MAX_TIMES; retryCount++) { if (DHContext::GetInstance().IsDeviceOnline(uuid)) { DHLOGW("device is already online, no need try disable, uuid = %s", GetAnonyString(uuid).c_str()); return result; -- Gitee From c088f29fa2232f18a52cb227de912087ddf3e522 Mon Sep 17 00:00:00 2001 From: tangfan <1824525929@qq.com> Date: Mon, 28 Mar 2022 19:12:01 +0800 Subject: [PATCH 2/4] fix log level Signed-off-by: tangfan <1824525929@qq.com> --- .../src/componentmanager/component_manager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp index 5ef2b8df..5f8970ae 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp @@ -224,12 +224,12 @@ int32_t ComponentManager::Enable(const std::string &networkId, const std::string dhId.c_str(), ret); for (int32_t retryCount = 0; retryCount < ENABLE_RETRY_MAX_TIMES; retryCount++) { if (!DHContext::GetInstance().IsDeviceOnline(uuid)) { - DHLOGW("device is already offline, no need try GetEnableParam, uuid = %s", + DHLOGE("device is already offline, no need try GetEnableParam, uuid = %s", GetAnonyString(uuid).c_str()); return ret; } if (GetEnableParam(networkId, uuid, dhId, dhType, param) == DH_FWK_SUCCESS) { - DHLOGI("GetEnableParam success, retryCount = %d", retryCount); + DHLOGE("GetEnableParam success, retryCount = %d", retryCount); break; } DHLOGE("GetEnableParam failed, retryCount = %d", retryCount); -- Gitee From 1d21045d08094ce9312d96951d33db0f49b3f644 Mon Sep 17 00:00:00 2001 From: tangfan <1824525929@qq.com> Date: Mon, 28 Mar 2022 19:23:14 +0800 Subject: [PATCH 3/4] fix enable log level Signed-off-by: tangfan <1824525929@qq.com> --- .../src/componentmanager/component_manager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp index 5f8970ae..b09c0ed5 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp @@ -241,11 +241,11 @@ int32_t ComponentManager::Enable(const std::string &networkId, const std::string if (result != DH_FWK_SUCCESS) { for (int32_t retryCount = 0; retryCount < ENABLE_RETRY_MAX_TIMES; retryCount++) { if (!DHContext::GetInstance().IsDeviceOnline(uuid)) { - DHLOGW("device is already offline, no need try enable, uuid = %s", GetAnonyString(uuid).c_str()); + DHLOGE("device is already offline, no need try enable, uuid = %s", GetAnonyString(uuid).c_str()); return result; } if (compEnable->Enable(networkId, dhId, param, find->second) == DH_FWK_SUCCESS) { - DHLOGI("enable success, retryCount = %d", retryCount); + DHLOGE("enable success, retryCount = %d", retryCount); return DH_FWK_SUCCESS; } DHLOGE("enable failed, retryCount = %d", retryCount); -- Gitee From 50e579db82bf96403514ecd2ef6d3c76d30d6aa5 Mon Sep 17 00:00:00 2001 From: tangfan <1824525929@qq.com> Date: Mon, 28 Mar 2022 19:36:47 +0800 Subject: [PATCH 4/4] add disable retry log level Signed-off-by: tangfan <1824525929@qq.com> --- .../src/componentmanager/component_manager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp index b09c0ed5..7b86679e 100644 --- a/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp +++ b/services/distributedhardwarefwkserviceimpl/src/componentmanager/component_manager.cpp @@ -269,11 +269,11 @@ int32_t ComponentManager::Disable(const std::string &networkId, const std::strin if (result != DH_FWK_SUCCESS) { for (int32_t retryCount = 0; retryCount < DISABLE_RETRY_MAX_TIMES; retryCount++) { if (DHContext::GetInstance().IsDeviceOnline(uuid)) { - DHLOGW("device is already online, no need try disable, uuid = %s", GetAnonyString(uuid).c_str()); + DHLOGE("device is already online, no need try disable, uuid = %s", GetAnonyString(uuid).c_str()); return result; } if (compDisable->Disable(networkId, dhId, find->second) == DH_FWK_SUCCESS) { - DHLOGI("disable success, retryCount = %d", retryCount); + DHLOGE("disable success, retryCount = %d", retryCount); return DH_FWK_SUCCESS; } DHLOGE("disable failed, retryCount = %d", retryCount); -- Gitee