From b2e2dd0c375de2cf3cc5922d67a7dc4f09b79a37 Mon Sep 17 00:00:00 2001 From: Leonid Chernin Date: Sun, 31 Dec 2023 06:44:19 +0000 Subject: [PATCH] my additions --- src/mon/NVMeofGwMap.cc | 2 +- src/mon/NVMeofGwMap.h | 7 +++ src/mon/NVMeofGwMon.cc | 108 +++++++++++++++++++++++++++++++++++- src/mon/NVMeofGwSerialize.h | 20 +++++-- 4 files changed, 128 insertions(+), 9 deletions(-) diff --git a/src/mon/NVMeofGwMap.cc b/src/mon/NVMeofGwMap.cc index fe2c3dcca36d..034c1cc835da 100755 --- a/src/mon/NVMeofGwMap.cc +++ b/src/mon/NVMeofGwMap.cc @@ -49,7 +49,7 @@ int NVMeofGwMap::cfg_add_gw(const GW_ID_T &gw_id, const GROUP_KEY& group_key) { GW_CREATED_T gw_created(i); Created_gws[group_key][gw_id] = gw_created; - dout(4) << __func__ << "Created GW: " << gw_id << " pool " << group_key.first << "group" << group_key.second + dout(4) << __func__ << "Created GW: " << gw_id << " pool " << group_key.first << " group " << group_key.second << " grpid " << gw_created.ana_grp_id << dendl; return 0; } diff --git a/src/mon/NVMeofGwMap.h b/src/mon/NVMeofGwMap.h index 43aba52cd355..1391e2b9bb88 100755 --- a/src/mon/NVMeofGwMap.h +++ b/src/mon/NVMeofGwMap.h @@ -59,6 +59,13 @@ class NVMeofGwMap void cancel_timer(const GW_ID_T &gw_id, const GROUP_KEY& group_key, const NQN_ID_T& nqn, ANA_GRP_ID_T anagrpid); public: + void debug_encode_decode(){ + ceph::buffer::list bl; + encode(bl); + auto p = bl.cbegin(); + decode(p); + } + void encode(ceph::buffer::list &bl, bool full_encode = true) const { using ceph::encode; __u8 struct_v = 0; diff --git a/src/mon/NVMeofGwMon.cc b/src/mon/NVMeofGwMon.cc index 6c5a434d9783..fb28844c4e11 100644 --- a/src/mon/NVMeofGwMon.cc +++ b/src/mon/NVMeofGwMon.cc @@ -36,6 +36,108 @@ void NVMeofGwMon::on_restart(){ void NVMeofGwMon::on_shutdown() {} +static int cnt ; +#define start_cnt 6 +void NVMeofGwMon::inject1(){ + //bool propose = false; + if( ++cnt == 4 ){// simulation that new configuration was added + std::string pool = "pool1"; + std::string group = "grp1"; + auto group_key = std::make_pair(pool, group); + pending_map.cfg_add_gw("GW1" ,group_key); + pending_map.cfg_add_gw("GW2" ,group_key); + pending_map.cfg_add_gw("GW3" ,group_key); + NONCE_VECTOR_T new_nonces = {"abc", "def","hij"}; + //ANA_GRP_ID_T grp = 1; + //pending_map.update_gw_nonce("GW1.g1.p1", grp, new_nonces); + pending_map.Created_gws[group_key]["GW1"].nonce_map[1] = new_nonces; + + // pending_map.update_gw_nonce("GW1.g1.p1", grp, new_nonces); + pending_map.Created_gws[group_key]["GW2"].nonce_map[2] = new_nonces; + GW_STATE_T gst1(1); + std::string nqn1 = "nqn2008.node1"; + pending_map.Gmap[group_key][nqn1]["GW2"] = gst1; + + GW_STATE_T gst2(2); + pending_map.Gmap[group_key][nqn1]["GW3"] = gst2; + dout(4) << pending_map << dendl; + + + pending_map.debug_encode_decode(); + dout(4) << "Dump map after decode encode:" <("mon_nvmeofgw_beacon_grace"); dout(4) << MY_MON_PREFFIX << __func__ << "NVMeofGwMon leader got a real tick, pending epoch "<< pending_map.epoch << dendl; @@ -371,7 +473,7 @@ bool NVMeofGwMon::preprocess_beacon(MonOpRequestRef op){ } -//#define BYPASS_GW_CREATE_CLI +#define BYPASS_GW_CREATE_CLI bool NVMeofGwMon::prepare_beacon(MonOpRequestRef op){ dout(4) << MY_MON_PREFFIX <<__func__ << dendl; @@ -397,7 +499,7 @@ bool NVMeofGwMon::prepare_beacon(MonOpRequestRef op){ else{ dout(4) << "GW " << gw_id << " sent beacon being in state GW_WAIT_INITIAL_MAP but it is not created yet!!! "<< dendl; #ifdef BYPASS_GW_CREATE_CLI - pending_map.cfg_add_gw(gw_id); + pending_map.cfg_add_gw(gw_id ,group_key); dout(4) << "GW " << gw_id << " created since mode is bypass-create-cli "<< dendl; propose= true; #endif diff --git a/src/mon/NVMeofGwSerialize.h b/src/mon/NVMeofGwSerialize.h index e99cb4c9b311..bb90b733dfe0 100755 --- a/src/mon/NVMeofGwSerialize.h +++ b/src/mon/NVMeofGwSerialize.h @@ -268,11 +268,11 @@ inline std::ostream& operator<<(std::ostream& os, const GROUP_KEY value) { }; inline std::ostream& operator<<(std::ostream& os, const GW_STATE_T value) { - os << "GW_STATE_T [ sm_state "; + os << "GW_STATE_T [ \n (gw-mon) sm_state "; for (int i = 0; i < MAX_SUPPORTED_ANA_GROUPS; i++) { os << value.sm_state[i] << ","; } - os << "] failover peers "; + os << "] \n (gw-mon) failover peers "; for (int i = 0; i < MAX_SUPPORTED_ANA_GROUPS; i++) { os << value.failover_peer[i] << ","; } @@ -285,7 +285,7 @@ inline std::ostream& operator<<(std::ostream& os, const GWMAP value) { for (auto& nqn_state: value) { os << " { nqn: " << nqn_state.first << " -> "; for (auto& gw_state: nqn_state.second) { - os << " { gw_id: " << gw_state.first << " -> " << gw_state.second << "}"; + os << "\n (gw-mon) { gw_id: " << gw_state.first << " -> " << gw_state.second << "}"; } os << "}"; } @@ -297,11 +297,21 @@ inline std::ostream& operator<<(std::ostream& os, const NVMeofGwMap value) { for (auto& group_state: value.Gmap) { os << " { " << group_state.first << " } -> { " << group_state.second << " }"; } - os << " ] [ Created_gws: "; + os << " ] \n (gw-mon)[ Created_gws: "; for (auto& group_gws: value.Created_gws) { os << " { " << group_gws.first << " } -> { "; for (auto& gw: group_gws.second) { - os << " { gw_id " << gw.first << " } -> { " << gw.second.ana_grp_id << " }"; + os << " \n (gw-mon) { gw_id " << gw.first << " } -> { ana-grp-id:" << gw.second.ana_grp_id << " nonces : " ; // << " }"; + // dump nonces map + if(gw.second.nonce_map.size()) + for( auto &nonce_map : gw.second.nonce_map){ + os << "ana_grp: " << nonce_map.first << " [ " ; + for (auto & nonces : nonce_map.second){ + os << nonces << " "; + } + os << "]" ; + } + } os << " }"; }