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 % 43 0
Test Date: 2026-08-04 10:52:23 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              : 
      14              : using namespace std;
      15              : using namespace hccl;
      16              : 
      17            0 : TopoinfoRoletable::TopoinfoRoletable(const std::string &rankTableM)
      18            0 :     : TopoInfoRanktableParser(rankTableM, "0")
      19              : {
      20            0 : }
      21              : 
      22            0 : TopoinfoRoletable::~TopoinfoRoletable()
      23              : {
      24            0 : }
      25              : 
      26            0 : HcclResult TopoinfoRoletable::GetSingleNode(const nlohmann::json &NodeListObj, u32 objIndex,
      27              :     std::vector<RoleTableNodeInfo> &nodes)
      28              : {
      29              :     u32 id;
      30            0 :     std::string ip;
      31            0 :     HcclIpAddress ipAddr;
      32              :     u32 port;
      33              : 
      34            0 :     if (GetJsonArrayMemberProperty(NodeListObj, objIndex, NODE_ID, id, true) == HCCL_E_NOT_FOUND) {
      35            0 :         HCCL_WARNING("[Parser][RoleTable]node id is not found!");
      36            0 :         id = INVALID_UINT;
      37              :     }
      38              : 
      39            0 :     CHK_RET(GetJsonArrayMemberProperty(NodeListObj, objIndex, NODE_IP, ip, false));
      40            0 :     CHK_RET(GetJsonArrayMemberProperty(NodeListObj, objIndex, NODE_PORT, port, false));
      41            0 :     CHK_RET(ConvertIpAddress(ip, ipAddr));
      42              : 
      43            0 :     RoleTableNodeInfo roleTableNodeInfo;
      44            0 :     roleTableNodeInfo.id = id;
      45            0 :     roleTableNodeInfo.ipAddr = ipAddr;
      46            0 :     roleTableNodeInfo.port = port;
      47              : 
      48            0 :     nodes.push_back(roleTableNodeInfo);
      49            0 :     return HCCL_SUCCESS;
      50            0 : }
      51              : 
      52            0 : HcclResult TopoinfoRoletable::GetServersInfo(std::vector<RoleTableNodeInfo> &servers)
      53              : {
      54            0 :     nlohmann::json serverList;
      55            0 :     CHK_RET(GetJsonProperty(fileContent_, SERVER_LIST, serverList, false));
      56              :     // 获得single server信息
      57            0 :     for (u32 index = 0; index < serverList.size(); index++) {
      58            0 :         CHK_RET(GetSingleNode(serverList, index, servers));
      59              :     }
      60            0 :     HCCL_INFO("get servers info success.");
      61            0 :     return HCCL_SUCCESS;
      62            0 : }
      63              : 
      64            0 : HcclResult TopoinfoRoletable::GetClientsInfo(std::vector<RoleTableNodeInfo> &clients)
      65              : {
      66            0 :     nlohmann::json clientList;
      67            0 :     CHK_RET(GetJsonProperty(fileContent_, CLIENT_LIST, clientList, false));
      68              :     // 获得single client信息
      69            0 :     for (u32 index = 0; index < clientList.size(); index++) {
      70            0 :         CHK_RET(GetSingleNode(clientList, index, clients));
      71              :     }
      72            0 :     HCCL_INFO("get clients info success.");
      73            0 :     return HCCL_SUCCESS;
      74            0 : }
      75              : 
      76            0 : HcclResult TopoinfoRoletable::ParserRoleTable(RoleTableInfo &roleTableInfo)
      77              : {
      78            0 :     CHK_RET(LoadConfigString(rankTableFile_));
      79            0 :     HCCL_INFO("ParserRoleTable [%s].", rankTableFile_.c_str());
      80            0 :     CHK_RET(GetServersInfo(roleTableInfo.servers));
      81            0 :     CHK_RET(GetClientsInfo(roleTableInfo.clients));
      82              : 
      83            0 :     return HCCL_SUCCESS;
      84              : }
        

Generated by: LCOV version 2.0-1