LCOV - code coverage report
Current view: top level - server/fsm - peek_state.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 19 19
Test Date: 2026-07-28 10:54:05 Functions: 100.0 % 4 4

            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 "fsm/peek_state.h"
      12              : #include "common/bqs_log.h"
      13              : #include "entity.h"
      14              : #include "state_manager.h"
      15              : namespace dgw {
      16              : 
      17           81 : FsmStatus PeekState::PreProcess(Entity &entity)
      18              : {
      19           81 :     DGW_LOG_INFO("[FSM] Entity id:[%u] type:[%s] state:[%s] desc:[%s].",
      20              :         entity.GetId(), entity.GetTypeDesc().c_str(),
      21              :         entity.GetStateDesc(FsmState::FSM_PEEK_STATE).c_str(), entity.ToString().c_str());
      22           81 :     FsmStatus status = entity.Dequeue();
      23           81 :     if (status == FsmStatus::FSM_FAILED) {
      24           31 :         return entity.ChangeState(FsmState::FSM_IDLE_STATE);
      25           50 :     } else if (status == FsmStatus::FSM_KEEP_STATE) {
      26           32 :         return FsmStatus::FSM_SUCCESS;
      27           18 :     } else if (status == FsmStatus::FSM_ERROR_PENDING) {
      28            3 :         return entity.ChangeState(FsmState::FSM_ERROR_STATE);
      29              :     } else {
      30           15 :         return PostProcess(entity);
      31              :     }
      32              : }
      33              : 
      34            6 : FsmStatus PeekState::ProcessMessage(Entity &entity, const InnerMessage &msg)
      35              : {
      36              :     (void)msg;
      37              :     // deque and schedule next data
      38            6 :     return PreProcess(entity);
      39              : }
      40              : 
      41           14 : FsmStatus PeekState::PostProcess(Entity &entity)
      42              : {
      43              :     // entity in group not need change to TRY_PUSH state, group need change to TRY_PUSH state
      44           14 :     if (entity.GetHostGroupId() != -1) {
      45              :         // keep current PEEK state
      46            1 :         return FsmStatus::FSM_SUCCESS;
      47              :     }
      48              : 
      49           13 :     entity.ResetSrcSubState();
      50              :     // change to TRY_PUSH state
      51           13 :     return entity.ChangeState(FsmState::FSM_TRY_PUSH_STATE);
      52              : }
      53              : 
      54            1 : FsmStatus GroupPeekState::PostProcess(Entity &entity)
      55              : {
      56              :     // change to TRY_PUSH state
      57            1 :     return entity.ChangeState(FsmState::FSM_TRY_PUSH_STATE);
      58              : }
      59              : 
      60              : REGISTER_STATE(FSM_PEEK_STATE, ENTITY_QUEUE, PeekState);
      61              : REGISTER_STATE(FSM_PEEK_STATE, ENTITY_TAG, PeekState);
      62              : REGISTER_STATE(FSM_PEEK_STATE, ENTITY_GROUP, GroupPeekState);
      63              : }  // namespace dgw
        

Generated by: LCOV version 2.0-1