LCOV - code coverage report
Current view: top level - legacy/ascend910/framework/common/src/topo - topoinfo_roletableParser.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 40 0
Test Date: 2026-08-18 17:47:01 Functions: 0.0 % 7 0

            Line data    Source code
       1              : /**
       2              :  * Copyright (c) 2025 Huawei Technologies Co., Ltd.
       3              :  * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
       4              :  * CANN Open Software License Agreement Version 2.0 (the "License").
       5              :  * Please refer to the License for details. You may not use this file except in compliance with the License.
       6              :  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
       7              :  * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
       8              :  * See LICENSE in the root of the software repository for the full text of the License.
       9              :  */
      10              : 
      11              : #include "topoinfo_roletableParser.h"
      12              : 
      13              : using namespace std;
      14              : using namespace hccl;
      15              : 
      16            0 : TopoinfoRoletable::TopoinfoRoletable(const std::string& rankTableM) : TopoInfoRanktableParser(rankTableM, "0") {}
      17              : 
      18            0 : TopoinfoRoletable::~TopoinfoRoletable() {}
      19              : 
      20              : HcclResult
      21            0 : TopoinfoRoletable::GetSingleNode(const nlohmann::json& NodeListObj, u32 objIndex, std::vector<RoleTableNodeInfo>& nodes)
      22              : {
      23              :     u32 id;
      24            0 :     std::string ip;
      25            0 :     HcclIpAddress ipAddr;
      26              :     u32 port;
      27              : 
      28            0 :     if (GetJsonArrayMemberProperty(NodeListObj, objIndex, NODE_ID, id, true) == HCCL_E_NOT_FOUND) {
      29            0 :         HCCL_WARNING("[Parser][RoleTable]node id is not found!");
      30            0 :         id = INVALID_UINT;
      31              :     }
      32              : 
      33            0 :     CHK_RET(GetJsonArrayMemberProperty(NodeListObj, objIndex, NODE_IP, ip, false));
      34            0 :     CHK_RET(GetJsonArrayMemberProperty(NodeListObj, objIndex, NODE_PORT, port, false));
      35            0 :     CHK_RET(ConvertIpAddress(ip, ipAddr));
      36              : 
      37            0 :     RoleTableNodeInfo roleTableNodeInfo;
      38            0 :     roleTableNodeInfo.id = id;
      39            0 :     roleTableNodeInfo.ipAddr = ipAddr;
      40            0 :     roleTableNodeInfo.port = port;
      41              : 
      42            0 :     nodes.push_back(roleTableNodeInfo);
      43            0 :     return HCCL_SUCCESS;
      44            0 : }
      45              : 
      46            0 : HcclResult TopoinfoRoletable::GetServersInfo(std::vector<RoleTableNodeInfo>& servers)
      47              : {
      48            0 :     nlohmann::json serverList;
      49            0 :     CHK_RET(GetJsonProperty(fileContent_, SERVER_LIST, serverList, false));
      50              :     // 获得single server信息
      51            0 :     for (u32 index = 0; index < serverList.size(); index++) {
      52            0 :         CHK_RET(GetSingleNode(serverList, index, servers));
      53              :     }
      54            0 :     HCCL_INFO("get servers info success.");
      55            0 :     return HCCL_SUCCESS;
      56            0 : }
      57              : 
      58            0 : HcclResult TopoinfoRoletable::GetClientsInfo(std::vector<RoleTableNodeInfo>& clients)
      59              : {
      60            0 :     nlohmann::json clientList;
      61            0 :     CHK_RET(GetJsonProperty(fileContent_, CLIENT_LIST, clientList, false));
      62              :     // 获得single client信息
      63            0 :     for (u32 index = 0; index < clientList.size(); index++) {
      64            0 :         CHK_RET(GetSingleNode(clientList, index, clients));
      65              :     }
      66            0 :     HCCL_INFO("get clients info success.");
      67            0 :     return HCCL_SUCCESS;
      68            0 : }
      69              : 
      70            0 : HcclResult TopoinfoRoletable::ParserRoleTable(RoleTableInfo& roleTableInfo)
      71              : {
      72            0 :     CHK_RET(LoadConfigString(rankTableFile_));
      73            0 :     HCCL_INFO("ParserRoleTable [%s].", rankTableFile_.c_str());
      74            0 :     CHK_RET(GetServersInfo(roleTableInfo.servers));
      75            0 :     CHK_RET(GetClientsInfo(roleTableInfo.clients));
      76              : 
      77            0 :     return HCCL_SUCCESS;
      78              : }
        

Generated by: LCOV version 2.0-1